//
//  HJDintegralViewController.m
//  常州红房子
//
//  Created by 胡金东 on 16/7/25.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDintegralViewController.h"
#import "HJDInterTableViewCell.h"
#import "HJDDetailInterViewController.h"

@interface HJDintegralViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView * inteTableView;
//等级图片
@property (nonatomic,strong) UIImageView *imgView ;

//等级昵称
@property (nonatomic,strong) UILabel *deleName;
//积分数
@property (nonatomic,strong) UILabel *sumLbl ;




@end

@implementation HJDintegralViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor getColorWithHexNumber:@"F1F0EE"];
    self.title = @"我的积分";
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor getColorWithHexNumber:@"848484"]}];
    
    
    UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 74, HJDWidth, 100)];
    bgView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bgView];
    self.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(21, 25, 30, 36)];
    self.imgView.image = [UIImage imageNamed:@"1我的积分"];
    [bgView addSubview:self.imgView];
    CGFloat deleNameX = CGRectGetMaxX(self.imgView.frame)+15;
    self.deleName = [[UILabel alloc]initWithFrame:CGRectMake(deleNameX, 25, 80, 20)];
    self.deleName.text = @"普通会员";
    self.deleName.font = [UIFont systemFontOfSize:19];
    self.deleName.textColor = [UIColor getColorWithHexNumber:@"323232"];
    [bgView addSubview:self.deleName];
    CGFloat interLblX = CGRectGetMaxX(self.imgView.frame)+15;
    CGFloat interLblY = CGRectGetMaxY(self.deleName.frame)+10;
    UILabel *interLbl = [[UILabel alloc]initWithFrame:CGRectMake(interLblX, interLblY, 40, 15)];
    interLbl.text = @"积分";
    interLbl.textColor = [UIColor getColorWithHexNumber:@"848484"];
    interLbl.font = [UIFont systemFontOfSize:15];
    [bgView addSubview:interLbl];
    
    CGFloat sumLblX = CGRectGetMaxX(interLbl.frame)+4;
    self.sumLbl = [[UILabel alloc]initWithFrame:CGRectMake(sumLblX, interLblY, 40, 15)];
    self.sumLbl.text = @"35";
    self.sumLbl.textColor = [UIColor getColorWithHexNumber:@"FF9BAA"];
    self.sumLbl.font = [UIFont systemFontOfSize:15];
    [bgView addSubview:self.sumLbl];
    
    CGFloat VviewX = CGRectGetMaxX(self.sumLbl.frame)+10;
    UIView *Vview = [[UIView alloc]initWithFrame:CGRectMake(VviewX, interLblY, 1, 13)];
    Vview.backgroundColor = [UIColor getColorWithHexNumber:@"EAE9E7"];
    [bgView addSubview:Vview];
    
    CGFloat btnX = CGRectGetMaxX(Vview.frame)+15;
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(btnX, interLblY, 40, 15)];
    [btn setTitle:@"规则" forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:15];
    [btn setTitleColor:[UIColor getColorWithHexNumber:@"848484"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    [bgView addSubview:btn];
    
    
    
    self.inteTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 120+64, HJDWidth, HJDHeight-200)];
    self.inteTableView.delegate = self;
    self.inteTableView.dataSource = self;
    [self.view addSubview:self.inteTableView];
    
//    UIView *lblView = [[UIView alloc]initWithFrame:CGRectMake(0, 10, HJDWidth, 50)];
//    lblView.backgroundColor = [UIColor whiteColor];
//    [self.inteTableView addSubview:lblView];
//    
//    UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 10, 100,50 )];
//    lbl.text = @"新手任务";
//    lbl.textColor = [UIColor getColorWithHexNumber:@"848484"];
//    lbl.font = [UIFont systemFontOfSize:15];
//    [lblView addSubview:lbl];

}

-(void)btnClick
{
    NSLog(@"规则");
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 4;
    }else if (section ==1){
        return 4;
    }else{
        return 4;
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = @"cell";
//    HJDInterTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    HJDInterTableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    
    if (cell == nil) {
        cell = [[HJDInterTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    if (indexPath.section ==0) {
        if (indexPath.row ==0) {
            cell.title.text = @"新手任务";
            cell.title.font = [UIFont systemFontOfSize:15];
            cell.title.textColor = [UIColor getColorWithHexNumber:@"848484"];

        }else if (indexPath.row == 1) {
            cell.title.text = @"分享宝妈";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];
        }else if (indexPath.row ==2){
            cell.title.text = @"上传头像";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }else {
            cell.title.text = @"绑定地址";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }
    }else if (indexPath.section ==1){
        if (indexPath.row ==0) {
            cell.title.text = @"每日任务";
            cell.title.font = [UIFont systemFontOfSize:15];
            cell.title.textColor = [UIColor getColorWithHexNumber:@"848484"];
        }else if (indexPath.row ==1) {
            cell.title.text = @"签到";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }else if (indexPath.row ==2){
            cell.title.text = @"连续签到七日";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }else {
            cell.title.text = @"分享四维彩超";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }
        
    }else if (indexPath.section ==2){
        if (indexPath.row ==0) {
            cell.title.text = @"其他任务";
            cell.title.font = [UIFont systemFontOfSize:15];
            cell.title.textColor = [UIColor getColorWithHexNumber:@"848484"];
        }else if (indexPath.row ==1) {
            cell.title.text = @"APP建议反馈";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }else if (indexPath.row==2){
            cell.title.text = @"生日积分";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

        }else{
            cell.title.text = @"活动积分";
            cell.imgView.image = [UIImage imageNamed:@"金币"];
            cell.sumLbl.text = @"+10";
            cell.iconImage.image = [UIImage imageNamed:@"cell"];

            
        }
    }

    return cell;
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            
        }else if (indexPath.row ==1){
            HJDDetailInterViewController *detail = [[HJDDetailInterViewController alloc]init];
            [self.navigationController pushViewController:detail animated:YES];
        }else if (indexPath.row ==2){
            
        }else {
            
        }
    }else if (indexPath.section ==1){
        if (indexPath.row == 0) {
            
        }else if (indexPath.row ==1){
            HJDDetailInterViewController *detail = [[HJDDetailInterViewController alloc]init];
            [self.navigationController pushViewController:detail animated:YES];
        }else if (indexPath.row ==2){
            
        }else {
            
        }
    }else{
        if (indexPath.row == 0) {
            
        }else if (indexPath.row ==1){
            HJDDetailInterViewController *detail = [[HJDDetailInterViewController alloc]init];
            [self.navigationController pushViewController:detail animated:YES];
        }else if (indexPath.row ==2){
            
        }else {
            
        }
    }
}

@end
